package com.czxy.service;

import com.czxy.client.UserClient;
import com.czxy.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

/**
 * @author 张青卯
 * @date Created in 10:50 2019/2/26
 */
@Service
public class AuthService {

    /**
     * userClient 远程调用接口
     */
    private final UserClient userClient;

    /**
     * @param userClient 进行接口注入
     */
    @Autowired
    public AuthService(UserClient userClient) {
        this.userClient = userClient;
    }

    /**
     * findUserByMobile 按用户名和地址传送到service系统比较
     * @param user 用户类
     * @return 返回查询到的用户信息
     */
    public User findUserByMobile(User user){
        ResponseEntity<User> entity = this.userClient.findUserByMobile(user.getName(), user.getSite());
        User body = entity.getBody();
        return body;
    }
}
